package com.firewolf.springboot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StuController {

	@Autowired
	private StuRespostory stuDao;
	
	/**
	 * 新增
	 * @return
	 */
	@RequestMapping("save")
	public String save(){
		Student s = new Student();
		s.setName("张三");
		stuDao.save(s);
		return "save ok";
	}
	
	/**
	 * 查询单个
	 * @return
	 */
	@RequestMapping("find")
	public Student findStu(){
		return stuDao.findOne(2);
	}
	
	/**
	 * 修改
	 * @return
	 */
	@RequestMapping("update")
	public Student update(){
		Student s = new Student();
		s.setId(2);
		s.setName("李四");
		return stuDao.save(s);
	}
	
	/**
	 * 删除
	 * @return
	 */
	@RequestMapping("delete")
	public String delete(){
		stuDao.delete(4);
		return "delete ok";
	}
}
